/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.oi.eksekutif.ui.model;

import com.oi.eksekutif.domain.Mobil;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author jasoet
 */
public class MobilTableModel extends AbstractTableModel {

    private List<Mobil> data;
    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");

    public MobilTableModel(List<Mobil> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return this.data.size();
    }

    @Override
    public int getColumnCount() {
        return 11;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Mobil o = data.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return o.getNomorPintu();
            case 1:
                return o.getNomorPolisi();
            case 2:
                return o.getNomorRangka();
            case 3:
                return o.getNomorMesin();
            case 4:
                return o.getMerkMobil();
            case 5:
                return simpleDateFormat.format(o.getTanggalArgo());
            case 6:
                return simpleDateFormat.format(o.getTanggalKir());
            case 7:
                return simpleDateFormat.format(o.getTanggalPengawasan());
            case 8:
                return simpleDateFormat.format(o.getTanggalStnk());
            case 9:
                return simpleDateFormat.format(o.getTanggalUsaha());
            case 10:
                return o.getJumlahSetoran();
            default:
                return "Invalid";
        }
    }

    @Override
    public String getColumnName(int column) {

        switch (column) {
            case 0:
                return "No. Pintu";
            case 1:
                return "No. Polisi";
            case 2:
                return "No. Rangka";
            case 3:
                return "No. Mesin";
            case 4:
                return "Merk";
            case 5:
                return "Tgl. Argo";
            case 6:
                return "Tgl. KIR";
            case 7:
                return "Tgl. Pengawasan";
            case 8:
                return "Tgl. STNK";
            case 9:
                return "Tgl. Usaha";
            case 10:
                return "Jumlah Setoran";
            default:
                return "Invalid";
        }

    }
}
